<script>
	export default {
		onLaunch() {
			// #ifdef APP-PLUS || APP-PLUS-NVUE
			//设置2.4秒后主动关闭，最多设置6秒
			setTimeout(() => {
				plus.navigator.closeSplashscreen();
			}, 4000);
			this.checkVersion()
			// #endif
		},
		onShow: function() {
			return;
			//console.log('App Show')
		},
		onHide: function() {
			//console.log('App Hide')
		},
		methods: {
			// #ifdef APP-PLUS || APP-PLUS-NVUE
			// app更新检测
			checkVersion() {
				// 获取应用版本号
				let version = plus.runtime.version;

				//检测当前平台，如果是安卓则启动安卓更新
				uni.getSystemInfo({
					success: res => {
						this.updateHandler(res.platform, version);
					}
				})
			},
			// 更新操作
			updateHandler(platform, version) {
				let data = {
					platform: platform,
					version: version
				}
				let _this = this;
				this.$api.APP(res => {
					const info = res.data;
					if (info.version !== '' && info.version > version) {
						console.log(info, version);
						uni.showModal({
							//提醒用户更新
							title: '更新提示',
							content: info.note,
							success: res => {
								if (res.confirm) {
									plus.runtime.openURL(info.down_url)
									setTimeout(() => {
										plus.runtime.quit()
									}, 1000)
								} else {
									plus.runtime.quit()
								}
							}
						})
					}

				})
			}
			// #endif
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "@/uni_modules/uview-ui/index.scss";
	@import './static/css/style.css';

	.flc {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.dis {
		display: flex;
	}

	.jus {
		display: flex;
		justify-content: center;
	}

	.ali {
		display: flex;
		align-items: center;
	}

	.demo {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	view {
		box-sizing: border-box;
	}

	.bgf {
		background: #fff;
	}

	.flc {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}


	.flc-inline {
		display: inline-flex;
		align-items: center;
	}

	.g5 {
		color: $g5;
	}

	.fz12 {
		font-size: $fz12;
	}
</style>
<style>
	@import url('/components/gaoyia-parse/parse.css');
</style>